import axios from "axios";

const UserStory ={
    namespaced: true,
    state:()=>({
        User_list:[],
        total:0
    }),
    mutations:{
        UserMutations(state,old){
            state.User_list =old
        },
        UserMutations_list(state,total){
            state.total=total
        }
    },
    actions:{
       UserAcyions(context,page={page:1,size:1}){
        var url = "/userlist?page="+page.page+"&size="+page.size
           axios.get(url).then(
               res=>{

                if(res.code == 403){
                    localStorage.removeItem('log_list')
                    window.location.href = "/#/login"
                   
                }else{
                    context.commit('UserMutations',res.list)
                }
                   
               }
           )
       },
       UserAcyions_list(context){
           axios.get('usercount').then(
               res=>{
               context.commit('UserMutations_list',res.list[0].total)
               }
           )
       }
    }
}
export default UserStory